
var CryptoJS = require("crypto-js");//replace thie with script tag in browser env
 
//encrypt

// var rawStr = "hello world!";
// var wordArray = CryptoJS.enc.Utf8.parse(rawStr);
// var base64 = CryptoJS.enc.Base64.stringify(wordArray);
// console.log('encrypted:', base64);
 
//decrypt

/**
 * 
 * @param {*} str base64解密数据
 */
const base64_decrypt = (str)=>{
    console.log("str",str)

    let parsedWordArray = CryptoJS.enc.Base64.parse(str);
    // return console.log(parsedWordArray)
    // console.log(parsedWordArray)
    return new Promise(async(resolve,reject) => {
        try {
            console.log("parsedWordArray",parsedWordArray.toString(CryptoJS.enc.Utf8))

            resolve(parsedWordArray.toString(CryptoJS.enc.Utf8))
        } catch (error) {
            reject('111')
        }
    })
}
export {base64_decrypt}
// console.log("parsed:",parsedStr);
